﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snowdreamist.Text.UBB
{
    /// <summary>
    /// Represent pure text without any format
    /// </summary>
    public sealed class TextElement : UBBElement
    {
        public TextElement(string value)
            : base(null)
        {
            if (value == null)
                value = string.Empty;
            this.Value = value;
        }

        /// <summary>
        /// The text value, fixed
        /// </summary>
        public string Value { get; private set; }

        public override string SerializeToUBBCode()
        {
            return this.Value;
        }

        public override void ToString(int indent, StringBuilder strBuilder)
        {
            if (indent != 0)
                strBuilder.Append(new string('\t', indent));
            strBuilder.Append(this.Value);
            strBuilder.Append('\n');
            base.SkipToString(indent, strBuilder);
        }

        public override object Clone()
        {
            return new TextElement(this.Value);
        }
    }
}